﻿using FineAdmin.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace FineAdmin.Web.Controllers
{
    public class MainController : Controller
    {
        // GET: Main
        public ISystemParameterService SystemParameterService { get; set; }
        public IICPLicenseService ICPLicenseService { get; set; }
        public ActionResult Index()
        {
            //如果是移动端或者带线报得域名 则跳转到移动端
            if (base.Request.Browser.IsMobileDevice || Request.Url.Host.Contains("xianbao"))
            {
                //Response.Redirect("http://blog.huijiyungo.com");
                return RedirectToAction("Index", "Mobile", false);
            }
            var TLD=Common.Common.GetTopDomainName(Request.Url.Host);
            var TLDInfo=ICPLicenseService.GetByWhere(" where DomainName = '"+ TLD+"'").FirstOrDefault();
            if (TLDInfo != null) {

                ViewBag.ICP = TLDInfo.ICP;
                ViewBag.GABEIAN = TLDInfo.PSNumber;
                ViewBag.GABEIANFULL = TLDInfo.PS;
            }
            else
            {
                ViewBag.ICP = SystemParameterService.GetByCode("ICP").SPValue;
                ViewBag.GABEIAN = SystemParameterService.GetByCode("GABEIAN").SPValue;//公安备案号 纯数字
                ViewBag.GABEIANFULL = SystemParameterService.GetByCode("GABEIANFULL").SPValue;//公安备案号 全名
            }
           
            return View();
        }
    }
}